﻿@using Lib.core;
@using Lib.helper;

@using Bll;
@using Model;
@using Model.Sys;
@using Hiwjcn.Web.Models.Link;
@using WebLogic.Model.Tag;
@{
    Layout = null;

    var model = ViewData["model"] as TagModel;
    if (model == null) { model = new TagModel(); }
}

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!-- header page -->
    @Html.Partial(IncludePath("header"))
    <style type="text/css">
        .input_group {
            margin: 5px 0px;
        }
    </style>
</head>

<body>
    @Html.Partial(IncludePath("body_top"))

    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <form id="fm">
                    <div class="box">
                        @if (model.TagID > 0)
                        {
                            <div class="pull-left">
                                <button class="btn btn-primary btn-x del" data-id="@(model.TagID)" type="button">删除</button>
                            </div>
                        }
                        <div class="pull-right">
                            <button class="btn btn-primary" type="submit">保存</button>
                        </div>
                    </div>
                    <div class="box">
                        <input type="hidden" name="id" value="@(model.TagID)" />
                        <div class="input_group">
                            <div>名称：</div>
                            <input type="text" class="form-control" name="name" value="@(model.TagName)" />
                        </div>
                        <div class="input_group">
                            <div>描述：</div>
                            <input type="text" class="form-control" name="desc" value="@(model.TagDesc)" />
                        </div>
                        <div class="input_group">
                            <div>连接：</div>
                            <input type="text" class="form-control" name="link" value="@(model.TagLink)" />
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            var form = $('#fm');
            form.submit(function () {
                var data = $(this).serializeArray();
                postJson('/admin/tag/SaveTagAction/', data, function (res) {
                    if (res && res.success) {
                        reload_parent();
                    }
                    else {
                        alert(res.msg);
                    }
                });
                return false;
            });
            $('.del').click(function () {
                if (!confirm('确定删除？')) { return false; }
                var id = $(this).attr('data-id');
                postJson('/admin/tag/DeleteTagAction/', { id: id }, function (res) {
                    if (res && res.success) {
                        reload_parent();
                    }
                    else {
                        alert(res.msg);
                    }
                });
                return false;
            });
        });
    </script>
</body>
</html>
